/*=============================================================================
#
# Author: haitao - haitao-330@sohu.com
#
# Last modified: 2015-12-30 11:37
#
# Filename: cnplayer.h
#
# Description: 
#
=============================================================================*/
#ifndef _CNPLAYER_H_
#define _CNPLAYER_H_

#ifndef DWORD
#define DWORD unsigned int
#endif
#ifndef PUCHAR
typedef unsigned char* PUCHAR; 
#endif
#ifndef UCHAR
#define UCHAR unsigned char
#endif

typedef int PLAYER_HANDLE;

class CCnPlayerPrivate;

class CCnPlayer
{
public:
    static CCnPlayer* Instance();

	static void ConvertYUVtoRGB(char* data, int yLen, int uLen, int vLen,
								int* pRGB,
								int width,int height, int uYStride, int uUVStride);

	CCnPlayer();

public:
	bool Init(const char* phoneno, const char* phone_version);
	void Dinit();

	PLAYER_HANDLE Connect(const char* url);
	void Disconnect(PLAYER_HANDLE handle);

    //0: 连接成功
    //1: 连接失败
    //2: 连接断开
    //3: 正在连接中
    //4: 未发动连接
	int GetConnectResult(PLAYER_HANDLE handle);

	//0:no error
	//1:数据缓存data太小
	//2:连接断开
    bool GetMediaData(PLAYER_HANDLE handle, char* data, int& len, int& yLen, int& uLen, int& vLen, long& w, long& h, int& yStride, int& uvStride, int& errcode, float& deviceFlowRate, float& clientFlowRate);
	bool GetMediaData(PLAYER_HANDLE handle, int* data, int& len, long& w, long& h, int& errcode, float& deviceFlowRate, float& clientFlowRate);
    
private:
	CCnPlayerPrivate* m_priv;
};

#endif
